﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Labthink.PCSoft.UniversalHost4.Model;
using Labthink.PCSoft.UniversalHost4.Model.Calibration;
using Labthink.PCSoft.UniversalHost4.Model.DataManage;
using Labthink.PCSoft.UniversalHost4.Model.Flow;
using Labthink.PCSoft.UniversalHost4.Model.Query;
using Labthink.PCSoft.UniversalHost4.Model.Setting;
using Labthink.PCSoft.UniversalHost4.Model.TempCtrl;
using Labthink.PCSoft.UniversalHost4.Model.Unit;
using Labthink.PCSoft.UniversalHost4.Model.User;
using Newtonsoft.Json;
using FullData = Labthink.PCSoft.UniversalHost4.Model.FullData;
using ParamScheme = Labthink.PCSoft.UniversalHost4.Model.ParamScheme;

namespace Labthink.PCSoft.UniversalHost4.TcpCommands
{
    public interface ICommands
    {
        #region 属性

        [JsonIgnore]
        bool IsConnected { get; }

        /// <summary>
        /// 数据连接,仅用于试验中的数据处理
        /// </summary>
        [JsonIgnore]
        [Obsolete("属性已过时，请直接使用接口中的事件")]
        SocketClient DataConnection { get;  }
        #endregion

        #region 事件
        /// <summary>
        /// 连接中断
        /// </summary>
        event EventHandler<EventArgs> OnDisConnectHandler;
        /// <summary>
        /// 实时数据
        /// </summary>
        event EventHandler<DataArgs> OnReceiveRealtimeDataHandler;
        /// <summary>
        /// 结果
        /// </summary>
        event EventHandler<DataArgs> OnReceiveResultsDataHandler;
        /// <summary>
        /// 参数
        /// </summary>
        event EventHandler<DataArgs> OnReceiveParamDataHandler;
        /// <summary>
        /// 试验全部开始
        /// </summary>
        event EventHandler<TestInfoArgs> OnReceiveAllTestStartHandler;
        /// <summary>
        /// 试验全部结束
        /// </summary>
        event EventHandler<TestInfoArgs> OnReceiveAllTestStopHandler;
        /// <summary>
        /// 试验开始
        /// </summary>
        event EventHandler<TestInfoArgs> OnReceiveTestStartHandler;
        /// <summary>
        /// 试验结束
        /// </summary>
        event EventHandler<TestInfoArgs> OnReceiveTestStopHandler;
        /// <summary>
        /// 试验状态
        /// </summary>
        event EventHandler<StatusArgs> OnReceiveTestStatusHandler;
        /// <summary>
        /// 报警信息
        /// </summary>
        event EventHandler<AlarmArgs> OnReceiveTestAlarmHandler;
        /// <summary>
        /// 自定义
        /// </summary>
        event EventHandler<CustomArgs> OnReceiveCustomHandler;
        /// <summary>
        /// 是否控制
        /// </summary>
        event EventHandler<BaseArgs> OnReceiveIsControlHandler;
        #endregion

        /// <summary>
        /// 数据转为事件
        /// </summary>
        /// <param name="sd"></param>
        /// <returns></returns>
        bool R2E(SocketData sd);
        Task<string> Init(string language);
        /// <summary>
        /// 初始化command
        /// </summary>
        /// <returns></returns>
        bool InitCommand(string con);
        /// <summary>
        /// 清理事件
        /// </summary>
        void ClearEvents();
        /// <summary>
        /// 设置混淆
        /// </summary>
        /// <param name="seed"></param>
        void SetMixSeed(string seed);

        #region 连接
        /// <summary>
        /// 测试连接
        /// </summary>
        /// <param name="con">连接地址（IP或COM）</param>
        /// <returns></returns>
        bool TestConnection(string con);
        /// <summary>
        /// 打开连接
        /// </summary>
        void OpenConnection();
        /// <summary>
        /// 重新连接
        /// </summary>
        void ReConnection();
        /// <summary>
        /// 关闭连接
        /// </summary>
        void CloseConnection();
        /// <summary>
        /// 开启心跳
        /// </summary>
        void StartHeart();
        /// <summary>
        /// 停止心跳
        /// </summary>
        void StopHeart();

        #endregion

        #region 参数
        /// <summary>
        /// 添加参数方案
        /// </summary>
        /// <param name="ps"></param>
        /// <returns></returns>
        Task<SocketData> AddParamSchemeAsync(ParamScheme ps);
        /// <summary>
        /// 更新参数方案
        /// </summary>
        /// <param name="ps"></param>
        /// <returns></returns>
        Task<SocketData> UpdateParamSchemeAsync(ParamScheme ps);
        /// <summary>
        /// 根据类型获取参数方案
        /// </summary>
        /// <param name="testType"></param>
        /// <returns></returns>
        Task<SocketData> GetParamSchemes(int testType);
        /// <summary>
        /// 根据ID获取参数方案
        /// </summary>
        /// <param name="id">方案ID</param>
        /// <returns></returns>
        Task<SocketData> GetParamSchemeByIdAsync(int id);
        /// <summary>
        /// 根据查询条件获取参数方案
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        Task<SocketData> GetParamSchemesAsync(QueryScheme query);
        /// <summary>
        /// 获取默认参数方案
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetDefaultParamSchemeAsync();
        /// <summary>
        /// 删除参数方案
        /// </summary>
        /// <param name="id">方案ID</param>
        /// <returns></returns>
        Task<SocketData> DeleteParamSchemeById(int id);
        /// <summary>
        /// 设置默认参数方案
        /// </summary>
        /// <param name="id">方案ID</param>
        /// <returns></returns>
        Task<SocketData> SetDefaultSchemeAsync(int id);

        #endregion

        #region 流程
        /// <summary>
        /// 获取流程配置文件
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetFlowConfigAsync();
        /// <summary>
        /// 保存流程配置文件
        /// </summary>
        /// <param name="datas"></param>
        /// <returns></returns>
        Task<SocketData> SetFlowConfigAsync(List<IniData> datas);

        #endregion

        #region 升级包
        /// <summary>
        /// 获取设备升级包版本
        /// </summary>
        /// <returns></returns>
        Task<string> GetUpdateVerForInstrumentAsync();
        /// <summary>
        /// 获取主程序升级包版本
        /// </summary>
        /// <returns></returns>
        Task<string> GetUpdateVerForUniversalHostAsync();
        /// <summary>
        /// 获取设备升级包
        /// </summary>
        /// <param name="ver"></param>
        /// <returns></returns>
        Task<string> GetUpdateForInstrument(string ver);
        /// <summary>
        /// 移除设备升级包
        /// </summary>
        /// <param name="ver"></param>
        /// <returns></returns>
        Task<string> RemoveUpdateForInstrumentAsync(string ver);
        /// <summary>
        /// 获取主程序升级包
        /// </summary>
        /// <param name="ver"></param>
        /// <returns></returns>
        string GetUpdateForUniversalHost(string ver);
        /// <summary>
        /// 移除设备升级包
        /// </summary>
        /// <param name="ver"></param>
        /// <returns></returns>
        Task<string> RemoveUpdateForUniversalHost(string ver);
        /// <summary>
        /// 获取升级包
        /// </summary>
        /// <returns></returns>
        Task<SocketData> CheckUpdateAsync();

        #endregion

        #region 设置
        /// <summary>
        /// 获取当前单位体系
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetCurrentUnitAsync();
        /// <summary>
        /// 根据单位获取模板文件
        /// </summary>
        /// <param name="unit"></param>
        /// <returns></returns>
        Task<string> GetCurrentDbTemplateAsync(string unit);
        /// <summary>
        /// 获取单位体系列表
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetUnitSysInfoAsync();

        /// <summary>
        /// 重启设备软件
        /// </summary>
        /// <returns></returns>
        Task<SocketData> DeviceResetAsync();

        /// <summary>
        /// 初始化设备
        /// </summary>
        /// <returns></returns>
        Task<SocketData> DeviceInitAsync();

        #region 报警
        /// <summary>
        /// 获取报警信息
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetAlarmPlugsAsync();
        /// <summary>
        /// 处理报警信息
        /// </summary>
        /// <param name="alarm"></param>
        /// <returns></returns>
        Task<SocketData> ProcessAlarms(Alarm alarm);
        /// <summary>
        /// 处理报警信息
        /// </summary>
        /// <param name="alarm"></param>
        /// <returns></returns>
        Task<SocketData> ProcessAlarmsByCode(Alarm alarm);
        #endregion

        #region 标定&量程
        /// <summary>
        /// 获取所有传感器
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetSensorsAsync();
        /// <summary>
        /// 获取所有标定信息
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetCaliRecordsAsync();
        /// <summary>
        /// 获取标定信息
        /// </summary>
        /// <param name="recordName">标定名称</param>
        /// <returns></returns>
        Task<SocketData> GetCaliRecordAsync(string recordName);
        /// <summary>
        /// 更新标定信息
        /// </summary>
        /// <param name="record"></param>
        /// <returns></returns>
        Task<SocketData> UpdateCaliRecordAsync(LineCaliRecord record);
        /// <summary>
        /// 删除标定信息
        /// </summary>
        /// <param name="recordName"></param>
        /// <returns></returns>
        Task<SocketData> DeleteCaliRecordAsync(string recordName);
        /// <summary>
        /// 设置默认标定
        /// </summary>
        /// <param name="recordName"></param>
        /// <returns></returns>
        Task<SocketData> SetDefaultCaliRecordAsync(string recordName);
        /// <summary>
        /// 获取传感器Ad和值
        /// </summary>
        /// <param name="sensor"></param>
        /// <returns></returns>
        Task<SocketData> GetAdAndValueAsync(Sensor sensor);
        /// <summary>
        /// 标定传感器
        /// </summary>
        /// <param name="cali"></param>
        /// <returns></returns>
        Task<SocketData> CaliSensorAsync(LineCali cali);
        /// <summary>
        /// 获取支持多量程的传感器
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetSensorRangesAsync();
        /// <summary>
        /// 获取所有量程
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetRangesAsync();
        /// <summary>
        /// 更新量程信息
        /// </summary>
        /// <param name="range"></param>
        /// <returns></returns>
        Task<SocketData> UpdateRangeAsync(Range range);
        /// <summary>
        /// 删除量程信息
        /// </summary>
        /// <param name="range"></param>
        /// <returns></returns>
        Task<SocketData> DeleteRangeAsync(Range range);
        /// <summary>
        /// 更改传感器量程
        /// </summary>
        /// <param name="range"></param>
        /// <returns></returns>
        Task<SocketData> ChangeRangeForSensorAsync(SensorRange range);
        #endregion

        #region 系统设置
        /// <summary>
        /// 同步设备时间
        /// </summary>
        /// <returns></returns>
        Task<SocketData> SetRemoteTimeAsync();
        /// <summary>
        /// 获取设备IP
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetRemoteIpAsync();
        /// <summary>
        /// 设置设备IP
        /// </summary>
        /// <param name="ip"></param>
        /// <returns></returns>
        Task<SocketData> SetRemoteIpAsync(Ip ip);
        /// <summary>
        /// 获取基本信息
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetBaseInfoAsync();
        /// <summary>
        /// 添加单位体系
        /// </summary>
        /// <returns></returns>
        Task<SocketData> AddUnitSysAsync();
        /// <summary>
        /// 添加单位体系包文件
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        Task<string> AddUnitSysAsync(string file);
        /// <summary>
        /// 删除单位体系
        /// </summary>
        /// <param name="units"></param>
        /// <returns></returns>
        Task<SocketData> DeleteUnitSysAsync(Units units);
        /// <summary>
        /// 设置默认单位体系
        /// </summary>
        /// <param name="units"></param>
        /// <returns></returns>
        Task<SocketData> SetDefaultUnitSysAsync(Units units);
        /// <summary>
        /// 获取默认单位体系压缩包
        /// </summary>
        /// <param name="unit"></param>
        /// <returns></returns>
        Task<string> GetDefaultUnitZipAsync(string unit);
        /// <summary>
        /// 设置基本信息
        /// </summary>
        /// <param name="bi"></param>
        /// <returns></returns>
        Task<SocketData> SetBaseInfoAsync(BaseInfo bi);
        /// <summary>
        /// 获取安全信息
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetSafeInfoAsync();
        /// <summary>
        /// 设置安全信息
        /// </summary>
        /// <param name="si"></param>
        /// <returns></returns>
        Task<SocketData> SetSafeInfoAsync(SafeInfo si);
        /// <summary>
        /// 获取磁盘信息
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetDiskInfoAsync();
        /// <summary>
        /// 设置磁盘信息
        /// </summary>
        /// <param name="di"></param>
        /// <returns></returns>
        Task<SocketData> SetDiskInfoAsync(DiskInfo di);
        #endregion

        #region 数据盾
        /// <summary>
        /// 获取数据盾配置
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetDsInfoAsync();
        /// <summary>
        /// 测试数据盾连接
        /// </summary>
        /// <param name="connectStr"></param>
        /// <returns></returns>
        Task<SocketData> DataShieldTestAsync(string connectStr);
        /// <summary>
        /// 保存数据库配置
        /// </summary>
        /// <param name="dsi"></param>
        /// <returns></returns>
        Task<SocketData> SetDsInfoAsync(DataShieldInfo dsi);
        #endregion

        #region 控制器
        /// <summary>
        /// 获取控制器实时值
        /// </summary>
        /// <param name="umc">控制器编号</param>
        /// <returns></returns>
        Task<SocketData> GetRealtimeTempAsync(int umc);
        /// <summary>
        /// 获取控制器类型列表
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetTempAsync();
        /// <summary>
        /// 获取控制器功能参数选项列表
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetTempCtrlFunAsync();
        /// <summary>
        /// 获取所有控制器列表
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetTempCtrlInfoAsync();
        /// <summary>
        /// 获取控制器参数值
        /// </summary>
        /// <param name="tpi"></param>
        /// <returns></returns>
        Task<SocketData> GetTempParamValueAsync(TpctParam tpi);
        /// <summary>
        /// 设置控制器参数值
        /// </summary>
        /// <param name="tpi"></param>
        /// <returns></returns>
        Task<SocketData> SetTempParamValueAsync(TpctParam tpi);
        /// <summary>
        /// 设置温控相关控制项状态
        /// </summary>
        /// <param name="tcii"></param>
        /// <returns></returns>
        Task<SocketData> SetTempControlledItemStatusAsync(ParamValue tcii);
        #endregion

        #region 自定义
        /// <summary>
        /// 发送自定义信息并返回值
        /// </summary>
        /// <param name="msgCode"></param>
        /// <param name="datas"></param>
        /// <returns></returns>
        Task<SocketData> SendCustomDataAsync(string msgCode, string datas = "");
        /// <summary>
        /// 发送自定义信息
        /// </summary>
        /// <param name="msgCode"></param>
        /// <param name="datas"></param>
        /// <returns></returns>
        Task<SocketData> SendCustomDataWithoutResponseAsync(string msgCode, string datas = "");

        #endregion

        #region 控制
        /// <summary>
        /// 开始试验（101）
        /// </summary>
        /// <param name="datas">附加数据</param>
        /// <returns></returns>
        Task<SocketData> StartTestAsync(string datas = "");
        /// <summary>
        /// 单次试验停止(并列试验)
        /// </summary>
        /// <param name="stopReturning">是否同时停止相应动作</param>
        /// <returns></returns>
        Task<SocketData> StopSingleTestAsync(bool stopReturning);
        /// <summary>
        /// 设置参数
        /// </summary>
        /// <param name="paramlist"></param>
        /// <returns></returns>
        Task<SocketData> SetTestParams(List<FullData> paramlist);
        /// <summary>
        /// 停止试验
        /// </summary>
        /// <param name="needSave">是否保存试验数据</param>
        /// <returns></returns>
        Task<SocketData> EndTestAsync(bool needSave);
        /// <summary>
        /// 停止试验(多腔中的某个腔)
        /// </summary>
        /// <param name="data">腔号</param>
        /// <returns></returns>
        Task<SocketData> EndTestAsync(string data);

        #endregion

        #region 数据

        /// <summary>
        /// 获取缓存数据
        /// </summary>
        /// <param name="index">数据索引</param>
        /// <returns></returns>
        Task<SocketData> GetCacheCountAsync(LostDataIndex index);

        #endregion

        #region GMP&电子签名
        /// <summary>
        /// 获取GMP信息
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetGmpInfoAsync();
        /// <summary>
        /// 保存GMP信息
        /// </summary>
        /// <param name="gi"></param>
        /// <returns></returns>
        Task<SocketData> SetGmpInfoAsync(GmpInfo gi);
        /// <summary>
        /// 获取电子签名信息
        /// </summary>
        /// <param name="qs"></param>
        /// <returns></returns>
        Task<SocketData> GetSignatureInfoAsync(QuerySign qs);
        /// <summary>
        /// 添加电子签名信息
        /// </summary>
        /// <param name="qs"></param>
        /// <returns></returns>
        Task<SocketData> AddSignatureInfoAsync(Esignal qs);
        /// <summary>
        /// 更新电子签名信息
        /// </summary>
        /// <param name="qs"></param>
        /// <returns></returns>
        Task<SocketData> ModifySignatureInfoAsync(Esignal qs);
        /// <summary>
        /// 删除电子签名信息
        /// </summary>
        /// <param name="qs"></param>
        /// <returns></returns>
        Task<SocketData> DeleteSignatureInfoAsync(Esignal qs);
        /// <summary>
        /// 获取已经加入追踪的参数
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetTracedParamsAsync();
        /// <summary>
        /// 获取可以加入追踪的参数
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetParamsForTraceAsync();
        /// <summary>
        /// 添加一个参数到追踪列表
        /// </summary>
        /// <param name="pft"></param>
        /// <returns></returns>
        Task<SocketData> InsertOneParamForTraceAsync(ParamForTrace pft);
        /// <summary>
        /// 从追踪表中一出一个参数
        /// </summary>
        /// <param name="pft"></param>
        /// <returns></returns>
        Task<SocketData> RemoveOneParamForTraceAsync(ParamForTrace pft);
        #endregion

        #region 远程连接
        /// <summary>
        /// 获取远程共享主机信息
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetRemoteHostAsync();
        /// <summary>
        /// 测试远程主机连接
        /// </summary>
        /// <param name="ri"></param>
        /// <returns></returns>
        Task<SocketData> TestRemoteHostAsync(RemoteInfo ri);
        /// <summary>
        /// 设置远程共享主机信息
        /// </summary>
        /// <param name="ri"></param>
        /// <returns></returns>
        Task<SocketData> SetRemoteHostAsync(RemoteInfo ri);
        #endregion

        #region 报告
        /// <summary>
        /// 获取报告配置信息
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetReportConfigsAsync();
        /// <summary>
        /// 更新报告配置信息
        /// </summary>
        /// <param name="cfg"></param>
        /// <returns></returns>
        Task<SocketData> UpdateReportConfigAsync(ReportConfig cfg);
        #endregion

        #region 自定义Logo
        /// <summary>
        /// 获取自定义信息
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetCustomInfoAsync();
        /// <summary>
        /// 更新自定义信息
        /// </summary>
        /// <param name="ci"></param>
        /// <returns></returns>
        Task<SocketData> UpdateCustomInfoAsync(CustomInfo ci);
        /// <summary>
        /// 发送自定义logo文件
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        Task<string> SendCustomLogoAsync(string file);
        /// <summary>
        /// 发送logo缩略图
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        Task<string> SendCustomThumbAsync(string file);
        /// <summary>
        /// 获取自定义logo
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        Task<(string result, string file)> GetCustomLogoAsync(string file);
        /// <summary>
        /// 获取自定义logo缩略图
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        Task<(string result, string file)> GetCustomThumbAsync(string file);

        #endregion

        #region 备份还原

        /// <summary>
        /// 获取设备上的U盘
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetUDiskAsync();
        /// <summary>
        /// 从设备端备份数据库
        /// </summary>
        /// <returns></returns>
        Task<SocketData> BackupDatabaseFromDeviceAsync();

        /// <summary>
        /// 从PC端备份数据库
        /// </summary>
        /// <returns></returns>
        Task<(string result, string file)> BackupDatabaseFromPcAsync();

        /// <summary>
        /// 从设备端还原数据库
        /// </summary>
        /// <returns></returns>
        Task<SocketData> RestoreDatabaseFromDeviceAsync();
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetBackupAutoAsync();

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        Task<SocketData> SetBackupAutoAsync(AutoBackupConfig cfg);

        Task<SocketData> GetDataManageRecordAsync(QueryBase query);
        Task<SocketData> UpdateBackupAsync(DataManageRecord record);
        /// <summary>
        /// 从PC端还原数据库
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        Task<string> RestoreDatabaseFromPcAsync(string file);
        /// <summary>
        /// 从设备端备份试验数据
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        Task<SocketData> BackupTestDataFromDeviceAsync(QueryBackup query);

        /// <summary>
        /// 从PC端备份试验数据
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        Task<(string result, string file)> BackupTestDataFromPcAsync(QueryBackup query);



        /// <summary>
        /// 从设备端导出试验数据
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        Task<SocketData> ExportTestDataFromDeviceAsync(QueryBackup query);

        /// <summary>
        /// 从PC端导出试验数据
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        Task<(string result, string file)> ExportTestDataFromPcAsync(QueryBackup query);

        /// <summary>
        /// 从设备端还原试验数据
        /// </summary>
        /// <returns></returns>
        Task<SocketData> RestoreTestDataFromDeviceAsync();

        /// <summary>
        /// 从PC端还原实验数据
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        Task<string> RestoreTestDataFromPcAsync(string file);
        #endregion

        #region 用户和角色
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        Task<SocketData> Login(User user);
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        Task<SocketData> ChangePassword(User user);
        /// <summary>
        /// 退出
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        bool Logout(User user);
        /// <summary>
        /// 获取用户权限
        /// </summary>
        /// <param name="uid">用户编号</param>
        /// <returns></returns>
        Task<SocketData> GetPermissionsByUserIdAsync(int uid);
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        Task<SocketData> AddUserAsync(UserInfo user);
        /// <summary>
        /// 查询用户
        /// </summary>
        /// <param name="qu"></param>
        /// <returns></returns>
        Task<SocketData> GetUsersAsync(QueryUser qu);
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="qu"></param>
        /// <returns></returns>
        Task<SocketData> GetUserInfoAsync(QueryUser qu);
        /// <summary>
        /// 修改用户
        /// </summary>
        /// <param name="ui"></param>
        /// <returns></returns>
        Task<SocketData> ModifyUserAsync(UserInfo ui);
        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="loginName"></param>
        /// <returns></returns>
        Task<SocketData> DeleteUserAsync(string loginName);
        /// <summary>
        /// 恢复用户
        /// </summary>
        /// <param name="loginName"></param>
        /// <returns></returns>
        Task<SocketData> RenewUserAsync(string loginName);
        /// <summary>
        /// 恢复用户
        /// </summary>
        /// <param name="loginName"></param>
        /// <returns></returns>
        Task<SocketData> LockUserAsync(string loginName);
        /// <summary>
        /// 自动锁定用户
        /// </summary>
        /// <param name="ui"></param>
        /// <returns></returns>
        Task<SocketData> LockUserAutoAsync(UserInfo ui);
        /// <summary>
        /// 解锁用户
        /// </summary>
        /// <param name="loginName"></param>
        /// <returns></returns>
        Task<SocketData> UnlockUserAsync(string loginName);
        /// <summary>
        /// 重置用户密码
        /// </summary>
        /// <param name="loginName"></param>
        /// <returns></returns>
        Task<SocketData> ResetPasswordAsync(string loginName);
        /// <summary>
        /// 检查角色是否存在
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        Task<SocketData> CheckRoleNameAsync(string name);
        /// <summary>
        /// 获取角色列表
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetRolesAsync();
        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="ris"></param>
        /// <returns></returns>
        Task<SocketData> AddRoleAsync(RoleInfoSimple ris);
        /// <summary>
        /// 更新角色
        /// </summary>
        /// <param name="ris"></param>
        /// <returns></returns>
        Task<SocketData> UpdateRoleAsync(RoleInfoSimple ris);
        /// <summary>
        /// 删除角色
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        Task<SocketData> DeleteRoleAsync(int roleId);
        /// <summary>
        /// 获取角色信息
        /// </summary>
        /// <param name="roleid"></param>
        /// <returns></returns>
        Task<SocketData> GetRoleInfoAsync(int roleid);
        /// <summary>
        /// 获取权限列表
        /// </summary>
        /// <returns></returns>
        Task<SocketData> GetPermissionsAsync();
        #endregion

        #region 日志
        /// <summary>
        /// 查询操作日志
        /// </summary>
        /// <param name="ql"></param>
        /// <returns></returns>
        Task<SocketData> GetOperateLogAsync(QueryLog ql);
        /// <summary>
        /// 导出运行日志
        /// </summary>
        /// <returns></returns>
        Task<(string result, string file)> GetRunnningLogFromPcAsync();
        /// <summary>
        /// 添加一条操作日志
        /// </summary>
        /// <param name="log"></param>
        /// <returns></returns>
        Task<SocketData> AddOpLogAsync(OperateLog log);

        #endregion

        #region 试验查询

        /// <summary>
        /// 获取试验记录
        /// </summary>
        /// <param name="qd"></param>
        /// <returns></returns>
        Task<SocketData> GetTestDataAsync(QueryData qd);

        /// <summary>
        /// 获取试验文件
        /// </summary>
        /// <param name="files">试验文件全路径</param>
        /// <returns>试验文件压缩包路径</returns>
        string GetTestDataFiles(List<string> files);
        /// <summary>
        /// 获取试验数据文件
        /// </summary>
        /// <param name="testid"></param>
        /// <returns></returns>
        string GetTestDataFile(int testid);

        /// <summary>
        /// 加入数据盾发送列表
        /// </summary>
        /// <param name="files"></param>
        /// <returns></returns>
        Task<SocketData> SendToDataShieldAsync(List<string> files);

        /// <summary>
        /// 获取数据盾发送记录
        /// </summary>
        /// <param name="qb"></param>
        /// <returns></returns>
        Task<SocketData> GetSendRecordsAsync(QueryBase qb);

        /// <summary>
        /// 删除数据盾发送记录
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        Task<SocketData> DeleteSendRecordAsync(string fileName);

        /// <summary>
        /// 删除全部数据盾发送记录
        /// </summary>
        /// <returns></returns>
        Task<SocketData> DeleteSendRecordsAsync();

        /// <summary>
        /// 删除试验数据
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        Task<SocketData> DeleteTestDatasAsync(List<int> ids);

        /// <summary>
        /// 获取标签和备注
        /// </summary>
        /// <param name="testId"></param>
        /// <returns></returns>
        Task<SocketData> GetTagAndRemarkAsync(int testId);

        /// <summary>
        /// 获取自定义查询条件
        /// </summary>
        /// <returns></returns>
       Task<SocketData> GetSelfQuerysAsync();

        /// <summary>
        /// 更新备注和标签
        /// </summary>
        /// <param name="tr"></param>
        /// <returns></returns>
        Task<SocketData> UpdateTagAndRemarkAsync(TagAndRemark tr);

        #endregion

        #endregion
    }

    /// <summary>
    /// 内核类型
    /// Remote 从远程加载，适用于Tcp连接底层
    /// Local 从本地加载，适用于串口连接底层
    /// </summary>
    public enum CoreType
    {
        /// <summary>
        /// 远程，Tcp方式连接
        /// </summary>
        Remote,

        /// <summary>
        /// 本地，串口方式连接
        /// </summary>
        Local
    }
}
